﻿using System;
using System.Windows.Data;
using SystemConvert = System.Convert;

namespace Red.Controls.Converters
{
    public sealed class BoolStringConverter : IValueConverter
    {
        #region IValueConverter implementation

        public object Convert( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture )
        {
            bool flag = false;
            if ( value is string )
            {
                if ( string.IsNullOrEmpty( (string)value ) == false )
                {
                    flag = SystemConvert.ToBoolean( value );
                }
            }
            return flag;
        }

        public object ConvertBack( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture )
        {
            bool flag = false;
            if ( value is bool )
            {
                flag = (bool)value;
            }
            return flag.ToString();
        }
        #endregion IValueConverter implementation
    }
}
